-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added condition when downloading record for notification with stream_status finished #102
Conversation
added missing imports in downloader.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR!
Code changes look good, tested with my camera working. Just minor update needed.
Let me know if you can do it or if not I can do it after merging your PR.
pytapo/media_stream/downloader.py
Outdated
import logging | ||
|
||
logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger is passed from Home Assistant to init.py as printDebugInformation
parameter.
I believe we should use the same approach here, use tapo object passed to Downloader class and use its function debugLog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can delete this and use self.tapo.debugLog() call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted and replaced logger.warning with debugLog
pytapo/media_stream/session.py
Outdated
# print(plaintext) | ||
|
||
# # Update our own sequence numbers to avoid collisions | ||
# if (seq is not None) and (seq > self._seq_counter): | ||
# self._seq_counter = seq + 1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this block of comments and also the print comments in this file for clarity.
pytapo/media_stream/downloader.py
Outdated
downloading = False | ||
break | ||
except JSONDecodeError: | ||
logger.warning("Unable to parse JSON sent from device") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use self.tapo.debugLog() call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Sure, i will do the changes now and push shortly. |
@JurajNyiri all done, if you need something else, just ask. |
Thank you! |
… with stream_status finished
Closes JurajNyiri/HomeAssistant-Tapo-Control#523
During the download of a record, the camera is sending a json response, notifying that the download finished.
Since the code is not ready for this notification, it never assumed a complete record, entering in a loop between retrying and downloading the same record.
This code prevents the situation, expecting to find the json response, and if such situation occurs, assumes that the download is finished.
For reference, the response to find is the following:
b'{"type":"notification", "params":{"event_type":"stream_status", "status":"finished"}}'
Also added missing dependency rtp for tox.